# 绝对引用，使我们的celery模块不会与原始的celery冲突
from __future__ import absolute_import, unicode_literals
# 导入原始的celery模块中shared_task    from xx import xx
from celery import shared_task
# 使用django内置函数发送邮件
from django.core.mail import send_mail
# 导入django的settings
from django.conf import settings


@shared_task
def send_email_task(username, token, email):
    subject = '美多商城会员注册'  # 发送主题
    message = ''
    from_email = settings.EMAIL_FROM  # 发件人
    recipient_list = [email]  # 收件人，列表
    html_message = '{}欢迎注册美多商城会员，请点击以下链接进行激活，<a href="http://127.0.0.1:8000/app01/active/?token={}">点击这里进行激活</a>'.format(username, token)  # html消息
    send_mail(subject, message, from_email, recipient_list, html_message=html_message)

